home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / wink2 / src / oak.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-26  |  2.1 KB  |  123 lines

  1. #include    <stdio.h>
  2. #include    <ctype.h>
  3. #include    <kkstr2.h>
  4. #include    "defs.h"
  5.  
  6. #define    MAX_MAC    512
  7.  
  8. extern char    *Act_vram();
  9. extern void    wrtstr();
  10. extern void    memcpy();
  11. extern void    memset();
  12. extern int    strlen();
  13. extern void    locate();
  14. extern char    *SPCSTR;
  15.  
  16. short  ReWrt_flg=FALSE;
  17.  
  18. static struct _MACRO {
  19.        int      mc_ch;
  20.        unsigned mc_ec;
  21.     } mac_key[MAX_MAC+1];
  22. static int    mac_cnt=0;
  23. static int    mac_max=0;
  24. static int    mac_flg=0;
  25.  
  26. static int       ch_bak;
  27. static unsigned ec_bak;
  28. static int       hit_flg=FALSE;
  29.  
  30. void    Tango_Touroku(char *str)
  31. {
  32.     int     x;
  33.     char    *vp;
  34.  
  35.     memset(str,80,0);
  36.     vp = (char *)Act_vram();
  37.     for ( x = Cur_X ; x < 80 ; x++ ) {
  38.     if ( (unsigned char)(*(str++) = *(vp+1)) < ' ' )
  39.         *(str-1) = ' ';
  40.     vp += 2;
  41.     }
  42. }
  43.  
  44. void    mac_save()
  45. {
  46.     switch(mac_flg) {
  47.     case 0: case 2:
  48.     mac_flg = 1;
  49.     mac_max = 0;
  50.     wrtstr("只今キ-マクロを定義中です",30,1,0x15);
  51.     break;
  52.     case 1:
  53.     mac_flg = 2;
  54.     mac_cnt = 0;
  55.     mac_max--;
  56.     wrtstr(SPCSTR,30,1,0x1F);
  57.     break;
  58.     }
  59. }
  60. void    mac_go()
  61. {
  62.     if ( mac_flg == 2 ) {
  63.     mac_flg = 3;
  64.     mac_cnt = 0;
  65.     }
  66. }
  67. int    kbhit()
  68. {
  69.     if ( hit_flg != FALSE )
  70.     return 1;
  71.  
  72.     if ( mac_flg == 3 ) {
  73.     if ( mac_cnt < mac_max ) {
  74.         hit_flg = TRUE;
  75.         ch_bak = mac_key[mac_cnt].mc_ch;
  76.         ec_bak = mac_key[mac_cnt].mc_ec;
  77.         mac_cnt++;
  78.         return 1;
  79.     } else {
  80.         mac_flg = 2;
  81.         mac_cnt = 0;
  82.     }
  83.     }
  84.  
  85.   do {
  86.     while ( (ch_bak = KYB_read(1,&ec_bak)) != 0xFFFF ) {
  87.     if ( ch_bak & 0x8000 || (ec_bak & 0xFF00) > 0x5100 )
  88.         ch_bak = 0xFFFF;
  89.     switch(ec_bak & 0xFF00) {
  90.     case 0xFF00:
  91.         break;
  92.  
  93.     default:
  94.         hit_flg = TRUE;
  95.         if ( mac_flg == 1 && mac_max < MAX_MAC ) {
  96.         mac_key[mac_max].mc_ch = ch_bak;
  97.         mac_key[mac_max].mc_ec = ec_bak;
  98.         mac_max++;
  99.         }
  100.         return 1;
  101.     }
  102.     }
  103.   } while ( KAN_inpchk() == KAN_MISET );
  104.  
  105.     return 0;
  106. }
  107. int    Get_key(ec)
  108. unsigned *ec;
  109. {
  110.     while ( kbhit() == 0 );
  111.     hit_flg = FALSE;
  112.     *ec = ec_bak & 0xFF14;
  113.     return ch_bak;
  114. }
  115. int    getch()
  116. {
  117.     int       ch;
  118.     unsigned  ec;
  119.  
  120.     while ( (ch = Get_key(&ec)) == 0xFFFF );
  121.     return ch;
  122. }
  123.